﻿#region 命名空间

using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sharp.Domain.PlatformBoundedContext.UserModule.Aggregates;

#endregion

namespace Sharp.Domain.PlatformBoundedContext.ModelConfigurations
{
    public partial class RoleTypeConfiguration : EntityTypeConfiguration<Role>
    {
        public RoleTypeConfiguration()
        {
            HasKey(c => c.Id);
            Property(c => c.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            Property(c => c.Name)
                .IsRequired()
                .HasMaxLength(25);
            Property(c => c.Remark)
                .IsOptional()
                .HasMaxLength(255);

            HasMany(t => t.Users)
             .WithMany(t => t.Roles)
             .Map(m =>
             {
                 m.ToTable("Platform_RoleUser");
                 m.MapLeftKey("RoleId");
                 m.MapRightKey("UserId");
             });
        }
    }
}